package com.dhcc.android.base.utils;

import android.content.Context;
import android.content.DialogInterface;
import android.support.v7.app.AlertDialog;

import com.dhcc.android.base.R;
import common.eric.com.ebaselibrary.util.ToastUtils;

/**
 * Created by eric on 2016/5/30.
 */
public class Msg {
    public static AlertDialog alertDialog;
    private static AlertDialog.Builder builder;

    public static void showInfo(Context context, String info) {
        ToastUtils.show(context, info);
    }

    public static void alertInfo(Context context, String info, DialogInterface.OnClickListener okOnclickListener) {
        if (alertDialog == null) {
            builder = new AlertDialog.Builder(context);
            builder.setMessage(info);
            builder.setTitle(R.string.alert_title);
            builder.setNegativeButton(R.string.alert_negative, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            });
            builder.setCancelable(true);
        }
        builder.setPositiveButton(R.string.alert_confirm, okOnclickListener);
        alertDialog = builder.show();
        alertDialog.setCanceledOnTouchOutside(false);
        alertDialog.show();
    }
}
